package com.edushare.common.dao;

import java.util.HashMap;
import java.util.List;

import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.query.SelectQuery;

import com.edushare.common.orm.ORMInterface;
import com.edushare.common.vo.Lookup;

public class LookupDAO extends CayenneBasedDAO {

	public LookupDAO(ORMInterface ormInterface) {
		super(ormInterface);
	}
	
	@SuppressWarnings("unchecked")
	boolean isIllegalInput(String input){
		boolean illegal = false;
		Expression exp = Expression.fromString("lookupType = $inputtype and lookupValue = $lookupval");
		HashMap hm = new HashMap();
		hm.put("inputtype", "ILLEGAL_VALUE");
		hm.put("lookupval", input);
		SelectQuery query = new SelectQuery(Lookup.class, exp.expWithParameters(hm));
		List lst = getDataContext().performQuery(query);
		if(lst!=null && lst.size() > 0)
			illegal = true;
		
		return illegal;
	}

}
